package org.apache.jsp.procesa;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.io.*;
import java.util.*;
import beans.BeanEnlaces;
import mapping.Enlace;
import mapping.UrlEnlace;

public final class proc_005fbusquedaenlace_005fadmin_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private javax.el.ExpressionFactory _el_expressionfactory;
  private org.apache.AnnotationProcessor _jsp_annotationprocessor;

  public Object getDependants() {
    return _jspx_dependants;
  }

  public void _jspInit() {
    _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
    _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
  }

  public void _jspDestroy() {
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"../error/errorpage.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write('\n');
      out.write('\n');
      out.write('\n');
      beans.BeanEnlaces mybean = null;
      synchronized (_jspx_page_context) {
        mybean = (beans.BeanEnlaces) _jspx_page_context.getAttribute("mybean", PageContext.PAGE_SCOPE);
        if (mybean == null){
          mybean = new beans.BeanEnlaces();
          _jspx_page_context.setAttribute("mybean", mybean, PageContext.PAGE_SCOPE);
        }
      }
      out.write("\n");
      out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
      out.write("<html>\n");
      out.write("<head>\n");
      out.write("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n");
      out.write("\t<!-- <script src=\"ajax/ajax_enlaces.js\" type=\"text/javascript\" charset=\"utf-8\"></script> -->\n");
      out.write("</head>\n");
      out.write("<body>\n");
      out.write("<div id = \"resultBusqEnlaces\">\n");
      out.write("\t");
		
		mybean.conectar();
		String [] tipoEnlacesElegidos = request.getParameterValues("tipo_enlace");
		String nombreEnlace = request.getParameter("nom_enlace");
		String urlenlace = request.getParameter("url_enlace");
		List listEnlacesPorTipo = mybean.getEnlaces(nombreEnlace, tipoEnlacesElegidos, urlenlace);
		if(listEnlacesPorTipo == null)
	       		out.println("<p>ERROR</p>");
		else {
      out.write("\n");
      out.write("\t\t<form id=\"formlistado\" action=\"proc_busquedaenlace_admin.jsp\" method=\"GET\" onsubmit=\"return false;\">\t\n");
      out.write("\t\t<table border=\"1\" width=\"100%\" valign=\"top\" cellspacing = \"0\" cellpadding=\"0\">\n");
      out.write("\t\t\t<tbody id=\"cuerpoTablaEnlaces\">\n");
      out.write("\t        <tr class=\"trcabeclista\">\n");
      out.write("\t        \t<td id=\"tdchkenlace\"><b>&nbsp;</b></td>\n");
      out.write("\t            <td id=\"tdnomenlace\"><b>NOMBRE</b></td>\n");
      out.write("\t            <td id=\"tdurlenlace\"><b>URL</b></td>\n");
      out.write("\t            <td id=\"tdtipoenlace\"><b>TIPO</b></td>\n");
      out.write("\t            <td id=\"tdbtenlace\">&nbsp;</td>\n");
      out.write("\t        </tr>\n");
      out.write("\t\t\t");

				Iterator it2 = listEnlacesPorTipo.iterator();
				while(it2.hasNext()) {
					Enlace enl = new Enlace();
					enl = (Enlace) it2.next();
					int id_enlace = enl.getId_enlace();
			
      out.write("\n");
      out.write("\t\t\t<tr class=\"listado\" id = \"fila");
      out.print(id_enlace);
      out.write("\" valign=\"top\" \n");
      out.write("\t\t\tonmouseover=\"iluminaFila(this)\" onmouseout=\"oscureceFila(this)\">\n");
      out.write("\t\t\t\t<td>\n");
      out.write("       \t\t\t\t<input type=\"checkbox\" class=\"chkboxes\" name=\"chkbx_enlaces\" id=\"");
      out.print(id_enlace);
      out.write("\"\n");
      out.write("       \t\t\t\tvalue=\"");
      out.print(id_enlace);
      out.write("\" onclick=\"habilitarEditarBorrar(this); habilitarBorrarTodo();\"/>\n");
      out.write("       \t\t\t</td>\n");
      out.write("\t\t\t\t<td id=\"tdnomenlace\">");
      out.print(enl.getEnlace());
      out.write("</td>\n");
      out.write("\t\t\t\t<td>\n");
      out.write("\t\t\t\t\t\n");
      out.write("\t\t       \t\t\t");
List listaUrls = enl.getListaUrls();
		                    if(listaUrls != null){
		                         Iterator it = listaUrls.iterator();
		                         while(it.hasNext()) {
		                         	UrlEnlace url = new UrlEnlace();
		                         	url = (UrlEnlace) it.next();
		                         	String str_url = url.getUrl_enlace();
		                         	String desc_url = url.getDescripcion_url();
		                         	if(desc_url == null) 
		                         		desc_url = "&nbsp;";
		                 
      out.write("\n");
      out.write("\t\t                   \n");
      out.write("\t\t                    \t<div id=\"tdurl\"><a href=\"");
      out.print(str_url);
      out.write("\" target=\"_blank\" title=\"");
      out.print(desc_url);
      out.write('"');
      out.write('>');
      out.print(str_url);
      out.write("</a></div>\t\t                       \n");
      out.write("\t\t                   \n");
      out.write("\t                         \t");
} // fin while
	                    	} // fin if
	                 
      out.write("\n");
      out.write("\t                      \n");
      out.write("\t       \t\t</td>\n");
      out.write("\t       \t\t\n");
      out.write("\t       \t\t<td>\n");
      out.write("\t       \t\t\t");
String nom_tipo = enl.getTipo_enlace();
      out.write("\n");
      out.write("\t       \t\t\t");
      out.print(nom_tipo);
      out.write(" \t\t\t \n");
      out.write("\t       \t\t</td>\n");
      out.write("\t       \t\t<td id=\"tdbtneditborrar\">\n");
      out.write("\t       \t\t\t<button id=\"btedit");
      out.print(id_enlace);
      out.write("\" onclick=\"editar(");
      out.print(id_enlace);
      out.write(")\" disabled>\n");
      out.write("\t       \t\t\t\t<img id=\"imgbtedit");
      out.print(id_enlace);
      out.write("\" src=\"images/web/editdis.ico\" alt=\"Editar\">\n");
      out.write("\t       \t\t\t</button>\n");
      out.write("\t       \t\t\t<button id=\"btborr");
      out.print(id_enlace);
      out.write("\" onclick=\"borrar()\" disabled=\"disabled\">\n");
      out.write("\t       \t\t\t\t<img id=\"imgbtborr");
      out.print(id_enlace);
      out.write("\" src=\"images/web/borradis.ico\" alt=\"Borrar\">\n");
      out.write("\t       \t\t\t</button>\n");
      out.write("\t       \t\t</td>\n");
      out.write("\t       \t\t");
}//fin while
	       		}//fin else
		mybean.desconectar();		

      out.write("\n");
      out.write("\t</tbody>\n");
      out.write("</table>\n");
      out.write("\t</form>\n");
      out.write("\t<br/>\n");
      out.write("\t\t<button id=\"btselect\" onclick=\"selectAll('chkboxes')\">Seleccionar todo</button>\n");
      out.write("    \t<button id=\"btunselect\" onclick=\"deselectAll('chkboxes')\">Deseleccionar todo</button>\n");
      out.write("    \t<button id=\"btborrartodo\" disabled=\"disabled\" onclick=\"borrar()\">Borrar seleccionados</button>\n");
      out.write("    \t\n");
      out.write("    <div id=\"res_borrado\"></div>\n");
      out.write("    <div id=\"modenlace\"></div>\n");
      out.write("</div>\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
